<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html;charset=UTF-8" language="java"  pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="spring" uri="/WEB-INF/lib/spring.tld"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f" %>
<%@ taglib prefix="z" uri="/WEB-INF/lib/zerdoor.tld"%>
<c:set value="${pageContext.request.contextPath}" var="path" scope="page"/>


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><spring:message code='artist_browse.title.msg' /></title>
    <link href="${path}/style/acg/css/style.css" rel="stylesheet" type="text/css" />

    <script src="${path}/js/jquery.min.js" type="text/javascript"></script>
    <link href="${path}/plugins/page/kkpager.css" rel="stylesheet">
    <script src="${path}/plugins/page/kkpager.js" type="text/javascript"></script>
    <%--<script type="text/javascript" src="${path}/style/acg/js/common.js"></script>--%>

    <script type="text/javascript">


        $(function(){
            initBeanInfo(1,10);
        });


        //跳转到确认作品订单页面
        function f_toConfirmPersonalOrder(){

            if("${curUser.userId}" == null || "${curUser.userId}" == ""){

                alert("<spring:message code='artist_home.alert.tipLogin' />");
                return;
            }

            window.location.href = "${path}/artistPersonalHome/confirmPersonalOrder.html?production_id="+${productionInfo.works_id};
        }



        //下载文件
        function f_download(url){

            if(url != null && url != ""){

                window.location.href = "${path}/fileDownload/download_file.html?res_url="+url;
            }


        }


        //  收藏
        function f_favorite(){

            if("${curUser.userId}" == null || "${curUser.userId}" == ""){

                alert("<spring:message code='artist_home.alert.tipLogin' />");
                return;
            }


            $.post("${path}/favorite/addFavorite.html",{collectId:${productionInfo.works_id},type:124101},function(result){

                if(result != "error"){

                    $(".favoriteP").html("<a href='javascript:f_reFavorite(\""+result+"\")' class=\"button\"><spring:message code='artist_home.msg.unsubscribe' /></a>");

                    $(".favorite_num").html(parseInt($(".favorite_num").html())  + 1);


                }else{
                    alert("<spring:message code='artist_home.alert.favoriteFailure' />");
                }
            });
        }

        //  取消收藏
        function f_reFavorite(favoriteId){


            $.post("${path}/favorite/removeFavorite.html",{favoriteId:favoriteId,collectId:${productionInfo.works_id},type:124101},function(result){

                if(result != "error"){

                    $(".favoriteP").html("<a href=\"javascript:f_favorite()\" class=\"button\"><spring:message code='artist_home.msg.collect' /></a>");

                    $(".favorite_num").html(parseInt($(".favorite_num").html())  - 1);
                }else{
                    alert("<spring:message code='artist_home.alert.favoriteFailure' />");
                }
            });
        }


        var pageSize = 10;
        /**查询任务信息*/
        function initBeanInfo(page, rows,keyword) {
            /**查询任务信息*/
            pageSize = rows;




            $.ajax({
                type: "POST",
                url: "${path}/itemAppraise/findWorksAppraiseByWorksId.html",
                data: {rows:rows, page:page,works_id:${productionInfo.works_id}},
                dataType: "json",
                success: function(data){
                    //console.log(data);

                    var html = "";
                    for(var i in data.list){

                        var bean = data.list[i];

                        html += " <tr>";
                        html += " <td>"+bean.nickname+"</td>";
                        html += " <td>"+f_formatAppraise(bean.total_appraise)+"</td>";
                        html += " <td title='"+bean.content+"'>"+f_formatContent(bean.content)+"</td>";
                        html += " <td>"+bean.appraise_time+"</td>";
                        html += " </tr>";

                    }


                    $("#dataBody").html(html);

                    var pager = data;
                    //分页
                    createPage(pager.pageNum, pager.pages, pager.total);

                }
            });
        }

        function f_formatContent(value){

            if(value.length < 30){

                return value;
            }else{

                value = value.substr(0,30);


                return value + "...";
            }

        }

        function f_formatAppraise(value){

            value = parseInt(value);

            var msg = "";
            switch (value){

                case 1:
                     msg = "<spring:message code="appraise.message.msg5"/>";
                     break;
                case 2:
                     msg = "<spring:message code="appraise.message.msg6"/>";
                    break;
                case 3:
                    msg = "<spring:message code="appraise.message.msg7"/>";
                    break;
                case 4:
                    msg = "<spring:message code="appraise.message.msg8"/>";
                    break;
                case 5:
                    msg = "<spring:message code="appraise.message.msg9"/>";
                    break;
            }
            var htmlstr = "";
            for(var i = 0; i < value; i ++){
                htmlstr += '<img  title="'+msg+'" src="${path}/style/acg/images/icon_star_2.gif">';
            }

            return htmlstr;

        }

        //分页方法
        //currentPage 当前页
        //rows 每页条数
        //total 总数
        function createPage(currentPage, totalPage, totalCount) {
            var totalPage = totalPage;
            var totalRecords = totalCount;
            var pageNo = currentPage;
            if (!pageNo) {
                pageNo = 1;
            }
            //生成分页
            //有些参数是可选的，比如lang，若不传有默认值
            kkpager.generPageHtml({
                pno: pageNo,
                //总页码
                total: totalPage,
                //总数据条数
                totalRecords: totalRecords,
                //链接前部
                hrefFormer: 'index',
                //链接尾部
                hrefLatter: '',
                //是否显示总页数
                isShowTotalPage: true,
                //是否显示总记录数
                isShowTotalRecords: true,
                //是否显示页码跳转输入框
                isGoPage: true,
                //getLink: function (n) {
                //    return this.hrefFormer + this.hrefLatter + "?pno=" + n;
                //}
                //,
                mode : 'click',//默认值是link，可选link或者click
                click : function(n){
                    //this.selectpage(n);
                    initBeanInfo(n, pageSize);
                    return false;
                },
                lang				: {
                    firstPageText			: '<spring:message code="firstPageText"/>',
                    firstPageTipText		: '<spring:message code="firstPageTipText"/>',
                    lastPageText			: '<spring:message code="lastPageText"/>',
                    lastPageTipText			: '<spring:message code="lastPageTipText"/>',
                    prePageText				: '<spring:message code="prePageText"/>',
                    prePageTipText			: '<spring:message code="prePageTipText"/>',
                    nextPageText			: '<spring:message code="nextPageText"/>',
                    nextPageTipText			: '<spring:message code="nextPageTipText"/>',
                    totalPageBeforeText		: '<spring:message code="totalPageBeforeText"/>',
                    totalPageAfterText		: '<spring:message code="totalPageAfterText"/>',
                    totalRecordsAfterText	: '<spring:message code="totalRecordsAfterText"/>',
                    gopageBeforeText		: '<spring:message code="gopageBeforeText"/>',
                    gopageButtonOkText		: '<spring:message code="gopageButtonOkText"/>',
                    gopageAfterText			: '<spring:message code="gopageAfterText"/>',
                    buttonTipBeforeText		: '<spring:message code="buttonTipBeforeText"/>',
                    buttonTipAfterText		: '<spring:message code="buttonTipAfterText"/>'
                }
            },true);
        }


        $(window).resize(function() {
            UpdateSize();
        });
        function closeWin(){
            $("#openwin").hide();
        }
        function openWin(){

            $("#openmain").load("${path}/itemAppraise/worksAppraise.html?works_id=${productionInfo.works_id}",function(){
                $("#openwin").show();
                UpdateSize();
            });


        }
        function UpdateSize(){
            var _width= parseFloat($(document).width());
            var _height=parseFloat($(window).height());
            if(_width<900){ _width=900;}
            if(_height<600){ _height=600;}
            var open_height=parseFloat($("#openbox").height());
            if(_height<open_height){_height=open_height;}
            var open_mt=(_height-open_height)/2;

            $("#openbox").css({"margin-top":open_mt+"px"});
            $("#openwin").css({"width":_width+"px","height":_height+"px"});
        }

    </script>

</head>

<body>
<div class="header">
    <jsp:include page="../public/header.jsp">
        <jsp:param    name="home"    value="dddd"    />
    </jsp:include>
</div>
<%--<div class="navbox">--%>
    <%--<div class="wrapper">--%>
    	<%--<ul class="navlist">--%>
            <%--<li><a href="index.html" class="dh_pack on">首页</a></li>--%>
            <%--<li><a href="Official.html" class="dh_pack">艺术家档案</a></li>--%>
            <%--<li><a href="" class="dh_pack">作品</a></li>--%>
            <%--<li><a href="Artist.html" class="dh_pack">交易评价</a></li>--%>
            <%--<li><a href="Contest.html" class="dh_pack">交易记录</a></li>--%>
        <%--</ul>--%>
    <%--</div>--%>
<%--</div>--%>
<div id="container">
    <div class="wrapper">
        <div class="listbox">
            <div class="modetitle">
                <spring:message code='artist_special.msg.currentLocation' />：<a href="${path}">ACG</a> >
                <a href="${path}/artistPersonalHome/artistPersonalHome.html?receiver=${productionInfo.navigation.artist_id}"><spring:message code='artist_special.msg.homepage' arguments='${productionInfo.navigation.real_name}' argumentSeparator=','/></a> >
                <a href="${path}/artistPersonalHome/artistPersonalSpecial.html?artistId=${productionInfo.navigation.artist_id}"><spring:message code='artist_special.msg.collections' /></a> >
                <a href="${path}/artistPersonalHome/artistProduction.html?photo_id=${productionInfo.navigation.photo_id}">${productionInfo.navigation.photo_name}</a> >
                ${productionInfo.navigation.works_name}
                <%--<span>--%>
                	<%--<a href="">按上传时间排序</a>--%>
                	<%--<a href="">按热度排序</a>--%>
                	<%--<a href="">按售价排列</a>--%>
                <%--</span>--%>
            </div>
            <div class="reelsshowmain">
                <div class="reels_title">${productionInfo.works_name}</div>
                <div class="reels_photos">
                	<div id="show-gallery" class="show-gallery">
                        
                        <c:forTokens items="${productionInfo.show_rul}" delims="," var="show_rul">

                            <div class="showcase-slide">
                                <div class="showcase-content">
                                    <img src="${path}/${show_rul}" width="1180" height="728" />
                                </div>
                                <div class="showcase-thumbnail">
                                    <img src="${path}/${show_rul}" width="146" height="90" />
                                </div>
                            </div>

                        </c:forTokens>
                        

                        
                    </div>
                </div>
                
                <div class="reelsshowmain">
        			<div class="reels_left">
                        <div class="reels_showtit"><spring:message code='artist_browse.msg.introductionWorks' /></div>
                        <div class="reels_content">
                            <p>
                                ${productionInfo.description}
                            </p>
                        </div>
                    </div>

                    <div class="reels_right">
                    	<div class="reels_showoper">
                            <p>
                                <c:if test="${productionInfo.orderId == null || productionInfo.orderId == ''}">
                                    <a href="javascript:f_toConfirmPersonalOrder()" class="button"><spring:message code='artist_browse.button.buy' /></a>


                                </c:if>
                                <c:if test="${productionInfo.orderId != null && productionInfo.orderId != ''}">
                                    <a href="javascript:f_download('${productionInfo.works_url}')" class="button"><spring:message code='artist_browse.button.download' /></a>
                                    <br/>
                                    <a href="javascript:void(0);" onclick="openWin()" class="button"><spring:message code='chatMain.message.msg25' /></a>

                                </c:if>

                            </p>
                            <p><spring:message code='artist_browse.msg.worksPrice' />：${productionInfo.price}<spring:message code='artist_browse.msg.yuan' /></p>
                        	<p><spring:message code='artist_browse.msg.sold' />：${productionInfo.sale_num}<spring:message code='artist_browse.msg.item' /></p>
                        	<p class="favoriteP">
                                <c:set var="favoriteId" scope="page" value="${z:findFavorite(curUser.userId, productionInfo.works_id, 124101)}"></c:set>

                                <c:if test="${favoriteId == null}">
                                    <a href="javascript:f_favorite();" class="button"><spring:message code='artist_home.msg.collect' /></a>
                                </c:if>

                                <c:if test="${favoriteId != null}">
                                    <a href='javascript:f_reFavorite("${favoriteId}")' class="button"><spring:message code='artist_home.msg.unsubscribe' /></a>
                                </c:if>

                            </p>
                        	<p><spring:message code='artist_home.msg.collect' />：<span class="favorite_num">${productionInfo.favorite_num}</span><spring:message code='artist_browse.msg.secondary' /></p>
                        </div>
                    	<ul>
                        	<li><img src="${path}/style/acg/images/reels_show_ad1.png" width="210" height="98" /></li>
                        	<li><img src="${path}/style/acg/images/reels_show_ad2.png" width="210" height="98" /></li>
                        </ul>
                    </div>
                    <div class="reels_left">
                        <div class="reels_showtit">作品评价</div>
                        <div class="reels_content">
                            <table style="width: 100%;">

                                <tr style="text-align: left;">
                                    <th style="width: 10%;">评价方</th>
                                    <th style="width: 10%;">整体评价</th>
                                    <th style="width: 50%;">评价内容</th>
                                    <th style="width: 30%;">评价时间</th>

                                </tr>
                                <tbody id="dataBody">

                                </tbody>
                            </table>
                            <div class="pagebox">
                                <div id="kkpager" style="text-align: center"></div>
                            </div>
                        </div>
                    </div>
                    <div class="clr"></div>
                </div>
            </div>
        </div>
    </div>

    <div id="openwin" class="openwin" style="width: 1382px; height: 600px;display: none">
        <div id="openbox" class="openbox" style="margin-top: 10.5px;">
            <h1><spring:message code='chatMain.message.msg1' /><span id="closeopen" class="closeopen" onclick="closeWin()">×</span></h1>
            <div id="openmain" class="openmain">

            </div>
        </div>
    </div>
</div>
<div id="footer">
    <!--content-->
    <jsp:include page="../public/footer.jsp"></jsp:include>

</div>
<script type="text/javascript" src="${path}/style/acg/js/jquery.aw-showcase.min.js"></script>
<script type="text/javascript" src="${path}/style/acg/js/scollphoto.js"></script>
</body>
</html>
